import * as Blockly from 'blockly/core';
import { Profile } from 'mixly';

const DISPLAY_HUE = 180;

// 覆盖原有的TFT_init_with_pin
export const TFT_init_with_pin = {
    init: function () {
        this.setColour(DISPLAY_HUE);
        this.appendDummyInput("")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_SETUP + " TFT " + Blockly.Msg.DISPLAY);
        this.appendDummyInput()
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MIXLY_STM32_TFT_GREENTAB + "(ST7735)", "INITR_GREENTAB"],
                [Blockly.Msg.MIXLY_STM32_TFT_REDTAB + "(ST7735)", "INITR_REDTAB"],
                [Blockly.Msg.MIXLY_STM32_TFT_BLACKTAB + "(ST7735)", "INITR_BLACKTAB"],
                ["160×80(ST7735)", "INITR_MINI160x80"],
                ["160×128(ST7789)", "128, 160"],
                ["240×135(ST7789)", "135, 240"],
                ["240×240(ST7789)", "240, 240"],
                ["320×240(ST7789)", "240, 320"],
                ["480×320(ST7796)", "480×320(ST7796)"]
            ]), "TYPE");
        //.appendField(" "+Blockly.Msg.MIXLY_MICROBIT_monitor)
        //.appendField(new Blockly.FieldDropdown(ROTATION_TYPE), "ROTATION");
        this.appendValueInput("CLK")
            .setCheck(Number)
            .appendField("CLK");
        this.appendValueInput("MOSI")
            .setCheck(Number)
            .appendField("SDA");
        this.appendDummyInput()
            .appendField('CS')
            .appendField(new Blockly.FieldDropdown(Profile.default.digital), "CS")
            .appendField('DC')
            .appendField(new Blockly.FieldDropdown(Profile.default.digital), "DC")
            .appendField('RST')
            .appendField(new Blockly.FieldDropdown(Profile.default.digital), "RST");
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
    }
};